package com.worldcup.utils;

import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author duwan.zq
 * @date 2018/06/06
 */
public class DateUtils {

    /**
     * 06月23日 15:00格式转换时区
     * @param time
     * @return
     */
    public static String toMosicoTimeString(String time){
        String[] time0 = time.split("年");
        String year = time0[0];
        String[] time1 = time0[1].split("月");
        String month = time1[0];
        String[] time2 = time1[1].split("日");
        String day = time2[0];
        String hour = time2[1].split(":")[0];
        ZonedDateTime zonedDateTime = ZonedDateTime.of(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day),
            Integer.parseInt(hour), 0, 0, 0, ZoneId.of("GMT+08:00"));
        //GMT+3.00
        return ZonedDateTime.ofInstant(zonedDateTime.toInstant(), ZoneId.of("GMT+3")).format(DateTimeFormatter.ofPattern("YYYY年MM月dd日 HH:mm"));
    }

    public static String toUAETimeString(String time){
        String[] time0 = time.split("年");
        String year = time0[0];
        String[] time1 = time0[1].split("月");
        String month = time1[0];
        String[] time2 = time1[1].split("日");
        String day = time2[0];
        String[] time3 = time2[1].split(":");
        String hour = time3[0].trim();
        String minute = time3[1];
        ZonedDateTime zonedDateTime = ZonedDateTime.of(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day),
            Integer.parseInt(hour), Integer.parseInt(minute), 0, 0, ZoneId.of("GMT+08:00"));
        //GMT+3.00
        return ZonedDateTime.ofInstant(zonedDateTime.toInstant(), ZoneId.of("GMT+4")).format(DateTimeFormatter.ofPattern("YYYY年MM月dd日 HH:mm"));
    }

}
